package com.atguigu.scala2.chapter2

import org.junit.Test

import java.net.URI
import scala.io.{Source, StdIn}

/**
 * @author lizikuan
 * @date 2021/7/12 19:05
 */
class Test1 {

  @Test
  def test1():Unit= {
    //单行注释
    /*
    多行注释
     */
  }

  //字符串的几种方式
  @Test
  def test2():Unit = {
    //1
    val str1 = new String("第一种")
    println(str1)

    //2
    val str2 = "第二种"
    println(str2)

    //3
    val str3 = s"${str2}第三种"
    println(str3)

    //4  输出中的format
    val str4 = "%s,%.2f,%d"
    println(str4.format("111",1.1,10))

    //5
    val sql =
      """
        |select
        |*
        |from stu1;
        |""".stripMargin
  }


  //从控制台输入
  @Test
  def test3() = {
//    val str = StdIn.readLine("请输入一行：")
//    println(str)

    //从文件输入
    val source = Source.fromFile("datas/data1.txt", "utf-8")
    println(source.getLines().toList)
  }


  @Test
  def test4() = {
    val a:Int = 10
    val b:Long = a
    println(b)
    val string = b.toInt.toString


  }
}
